﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for EditEventWindow.xaml
    /// </summary>
    public partial class TYGRQMPDC : UIPDC
    {
        ITXEXRPT ITXEXRPT;
        public TYGRQMPDC()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VICC_PDC();
            this.DataContext = MV;
            InitializeComponent();
            if (app.User.Trim() == "ITXV")
            {
                DTSTART = "20150820";
                DTEND = "20150901";
            }
        }
        public override void DTEND_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
        {
            base.DTEND_SelectedDateChanged(sender, e);
        }
        private void btnSum_Click(object sender, RoutedEventArgs e)
        {

            if (DTSTART == "")
            {
                DTSTART = "20000000";
            }
            if (DTEND == "")
            {
                DTEND = "99999999";
            }
            dwData = TBMain.NewRow();
            dwData["PDCDATE"] = " AND PDCDATE >=" + DTSTART + " AND PDCDATE <=" + DTEND; 
            dwData["ABFAGANG"] = "XS";
            SResult = TMV.QPDC06(dwData);
            MergeData(SResult, false);
        }
        private void btnExport_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (ITXEXRPT == null)
                {
                    ITXEXRPT = new ITXEXRPT();//这里是实例化
                    ITXEXRPT.Root = "C:\\IntexReport";
                    ITXEXRPT.strCompany = app.company;
                    ITXEXRPT.PrintType = "OpenExcel";
                }
                ITXEXRPT.dsSource = new System.Data.DataSet();
                ITXEXRPT.dsSource.Merge(TMV.SetProd);
                ITXEXRPT.DocType = app.company + "PDCTOT";
                ITXEXRPT.strExcelFile = app.company + @"\YGRREPORT.xls";
                string filename = ITXEXRPT.WriteExcelReport();
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
                MessageBox.Show(ex.StackTrace, ex.Message);
            }
        }
    }
}
